#include<stdio.h>
int main()
{
	int m, n;
	int arr1[10][10] = { 0 }; int arr2[10][10] = { 0 };
	while (scanf_s("%d%d", &n, &m) != EOF)
	{
		int i, j;
		for (i = 0; i < n; i++)
		{
			for (j = 0; j < m; j++)
			{
				scanf_s("%d", &arr1[i][j]);
			}
		}
		for (i = 0; i < m; i++)
		{
			for (j = 0; j < n; j++)
			{
				arr2[i][j] = arr1[j][i];
			}
		}
		for (i = 0; i < m; i++)
		{
			for (j = 0; j < n; j++)
			{
				printf("%d ", arr2[i][j]);
			}
			printf("\n");
		}
	}


	return 0;
}